package com.szpx.mapper;

import com.szpx.entity.TbComment;
import com.szpx.vo.TbCommentVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (TbComment)表数据库访问层
 *
 * @author ljx
 * @since 2024-04-07 23:09:26
 */
@Mapper
public interface TbCommentMapper {

    /**
     * 查询指定行数据
     *
     * @param tbComment 查询条件
     * @return 对象列表
     */
    @Select("select t1.*,t2.username as userName from tb_comment t1 inner join tb_user t2 on t1.user_id = t2.uid  where t1.god_id = #{godId}")
    List<TbCommentVo> queryAll(TbComment tbComment);


    /**
     * 新增数据
     *
     * @param tbComment 实例对象
     * @return 影响行数
     */
    @Insert(" insert into tb_comment (god_id,content,user_id,create_time) values (#{godId},#{content},#{userId},#{createTime})")
    int insert(TbComment tbComment);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    @Delete(" delete from tb_comment where id = #{id}")
    int deleteById(Integer id);

}

